package com.itmuch.cloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.cloud.netflix.zuul.filters.discovery.PatternServiceRouteMapper;
import org.springframework.context.annotation.Bean;


/**
 * Gateway服务网关：
 *  zuul:
 *    使用正则表达式指定路由规则:
 *    	启动项目：eureka,microservice-simple-provider-user,microservice-gateway-zuul-exp
 *       1.在主类添加bean
 *       2.在user项目的配置添加，多了个v1
 *       application:
 *        name: microservice-provider-user-v1
 *       3.浏览器访问地址：http://localhost:8041/v1/microservice-provider-user/simple/1           
 *                  
 */
@EnableZuulProxy
@SpringBootApplication
public class ZuulExpApplication {
	
	@Bean
	public PatternServiceRouteMapper serviceRouteMapper() {
		return new PatternServiceRouteMapper("(?<name>^.+)-(?<version>v.+$)", "${version}/${name}")  ;
	}
	
	
	public static void main(String[] args) {
		SpringApplication.run(ZuulExpApplication.class, args);
		
	}
	
	
}
